package com.esl.model.admin;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name = "T_Resource")
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public class Resource implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -1607542269073053025L;
	private String id;
	private String name;
	private String url;
	private String kind;
	private Date time = new Date();
	private String brief;
	private Integer count;
	private String temp;
	private User user;

	/*----------------------------------*/
	public Resource() {
		super();
	}

	public Resource(String id, String name, String url, String kind,
			String brief, String domainname, User user) {
		super();
		this.id = id;
		this.name = name;
		this.url = url;
		this.kind = kind;
		this.brief = brief;
		this.count = 0;
		this.temp = domainname;
		this.user = user;
	}

	/*----------------------------------*/
	public Resource(User user, String name, String url, String kind,
			String brief) {
		super();
		this.user = user;
		this.name = name;
		this.url = url;
		this.kind = kind;
		this.brief = brief;
	}

	public Resource(String name, String kind, String temp) {
		super();
		this.name = name;
		this.kind = kind;
		this.temp = temp;
	}

	@ManyToOne
	@JoinColumn(name = "u_uid")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "r_id", unique = true, nullable = false)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "r_name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "r_url")
	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Column(name = "r_kind")
	public String getKind() {
		return kind;
	}

	public void setKind(String kind) {
		this.kind = kind;
	}

	@Column(name = "r_time")
	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	@Column(name = "r_brief")
	public String getBrief() {
		return brief;
	}

	public void setBrief(String brief) {
		this.brief = brief;
	}

	@Column(name = "r_count")
	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

	@Column(name = "r_temp")
	public String getTemp() {
		return temp;
	}

	public void setTemp(String temp) {
		this.temp = temp;
	}
}
